﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace BHair
{
    public partial class frmcarddaoru : Form
    {
        public frmcarddaoru()
        {
            InitializeComponent();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string sql =string.Format( "UPDATE [BHairDB].[dbo].[制卡] SET [可用] = 0 WHERE card='{0}'", this.dataGridView1.Rows[i].Cells[0].Value.ToString());
                SqlCommand comm = new SqlCommand(sql,conn);
                comm.ExecuteNonQuery();
            }
            MessageBox.Show("重写完成");
            conn.Close();
        }

        private void frmcarddaoru_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = "select mid as 卡号 from member ";
            SqlDataAdapter sda = new SqlDataAdapter(sql,conn);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            dataGridView1.DataSource = dt;
            conn.Close();
        }
    }
}
